<div class="boxed">
    <div id="content-container">
        <div id="page-title">
            <h1 class="page-header text-overflow">Data Tables</h1>
            <div class="searchbox">
                <div class="input-group custom-search-form">
                    <input type="text" class="form-control" placeholder="Search..">
                    <span class="input-group-btn">
                        <button class="text-muted" type="button"><i class="demo-pli-magnifi-glass"></i></button>
                    </span>
                </div>
            </div>
        </div>
        <ol class="breadcrumb">
            <li><a href="{:url('Admin/Index/index')}">首页</a></li>
            <li>陪玩控制台</li>
            <li class="active">用户管理</li>
        </ol>
        <div id="page-content">
            <div class="panel">
                <div class="panel-heading">
                    <h3 class="panel-title">
                        <button class="btn btn-primary">界面管理</button>
                        <button class="btn btn-info">标签管理</button>
                    </h3>
                </div>
                <div class="panel-body">
                    <table id="demo-dt-basic" class="table table-striped table-bordered" cellspacing="0" width="100%">
                        <thead>
                        <tr>
                            <th>ID</th>
                            <th>昵称</th>
                            <th>头像</th>
                            <th>标签</th>
                            <th>地址</th>
                            <th>性别</th>
                            <th>手机号</th>
                            <th>openid</th>
                            <th>添加时间</th>
                            <th>家园</th>
                            <th align="center">在线状态</th>
                            <th class="min-tablet">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {foreach name="list" id="v"}
                        <tr>
                            <td>{$v['user_id']}</td>
                            <td>{$v['user_nickname']}</td>
                            <td style="cursor:pointer" onclick="rule.showUserSet('{$v.user_avatar}')">
                                <img src="{$v['user_avatar']}" width="30">
                            </td>
                            <td>
                                <span class="btn btn-rounded btn-labeled">{$v['tag_name']}</span>
                            </td>
                            <td>{$v['user_address']}</td>
                            <td align="center">
                                {eq name="$v.user_sex" value="1"}
                                <button class="btn btn-xs btn-success">男生</button>
                                {else/}
                                <button class="btn btn-xs btn-default">女生</button>
                                {/eq}
                            </td>
                            <td>{$v['user_mobile']}</td>
                            <td>{$v['user_openid']}</td>
                            <td>{$v['user_update']}</td>
                            <td style="cursor:pointer" onclick="rule.showUserSet('{$v.set_backgroundImg}')">
                                {eq name="$v.set_backgroundImg" value=""}无{else/}背景图{/eq}
                            </td>
                            <td align="center">
                                {eq name="$v.user_online" value="1"}
                                <button class="btn btn-xs btn-success">在线</button>
                                {else/}
                                <button class="btn btn-xs btn-default">离线</button>
                                {/eq}
                            </td>
                            <td>
                                {eq name="$v.user_status" value="1"}
                                <button class="btn btn-xs btn-info" onclick="rule.confim('{$v['user_id']}',0)">禁封</button>
                                {else/}
                                <button class="btn btn-xs btn-danger" onclick="rule.confim('{$v['user_id']}',1)">解封</button>
                                {/eq}
                            </td>
                        </tr>
                        {/foreach}
                        </tbody>
                    </table>
                    <div id="page" style="text-align:right">
                        {$page}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 修改菜单模态框结束 -->
<script type="text/javascript">
    var rule = {
        add:function () {
            this.open('#thinkright-add');
        },
        edit:function (obj) {
            setTimeout(function () {
                $("input[name='id']").val(obj.id);
                $("input[name='title']").val(obj.title);
                $("input[name='name']").val(obj.name);
                $("input[name='description']").val(obj.description);
                $("input[name='editor']").val(obj.id);
                $("input[name='icon']").val(obj.icon);
                $('.status'+obj.status).attr('checked',true).siblings('input').remove('checked');
                $('.func'+obj.func).attr('checked',true).siblings('input').remove('checked');
                $('.pid_'+obj.pid).attr('selected','selected').siblings('option').remove('selected');
                $('.submitDoc').text('编辑表单');
                $('#myModalLabel').text('编辑菜单')
            },500);
            this.open('#thinkright-add');
        },
        open:function (name) {
            layer.open({
                type: 1,
                shade: 0.6,
                title: false, //不显示标题
                area: ['600px', '680px'], //宽高
                scrollbar: false,
                content:$(name).html(),
                cancel: function(){}
            });
        },
        child:function (obj) {
            var ruleId=$(obj).attr('ruleId');
            $("input[name='pid']").val(ruleId);
            this.add();
        },
        submit:function () {
            form.ajax('#ruleAdd',function (res) {
                layer.msg(res.msg,function () {
                    if(res.code > 0){
                        layer.closeAll();
                        location.reload();
                    }
                })
            })
        },
        del:function (obj) {
            layer.confirm('你确定要删除吗?', {
                btn: ['删除','取消'] //按钮
            }, function(){
                $.post(obj.attr('href'), function(data) {
                    layer.msg(data.msg, {icon: 1},function () {
                        if(data.code > 0){
                            layer.closeAll();
                            location.reload();
                        }
                    });
                });
            }, function(){
            });
        },
        showUserSet:function (img) {
            if(!img){
                layer.msg('暂无设置...');
                return false;
            }
            layer.open({
                type: 1,
                shade: 0.6,
                title: false, //不显示标题
                scrollbar: false,
                content:"<img style='width:100%;height:100%;max-width:480px;' src='"+img+"'></img>",
                cancel: function(){}
            });
        },
        confim:function (status,tysg) {
            layer.confirm('确定要禁封吗？', {
                btn: ['封掉','算了'] //按钮
            }, function(){
                $.post('/index.php/Admin/user/userEdit',{
                    value:tysg,
                    name:'user_status',
                    uid:status
                }, function(data) {
                    layer.msg(data.msg, {icon: 1});
                   if(data.code > 0){
                       location.reload();
                   }
                });
            }, function(){});
        }
    };
</script>